/*
 * Iparelan Annotations Utilities
 * This file is part of Pattern Notes.
 * Copyright (c) 2008, Iparelan Solutions, LLC. All rights reserved.
 *
 * Pattern Notes is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Pattern Notes is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Pattern Notes. If not, see <http://www.gnu.org/licenses/>.
 */

package com.iparelan.annotations.patterns;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.iparelan.annotations.Copyright;

/**
 * Marks a class as implementing the Singleton pattern.
 *
 * <p>There are several ways to implement the singleton pattern, but all of
 * them strive to prohibit multiple instantiations of the singleton type by
 * implementing an instantiation constraint.
 *
 * <p>Usually this constraint is implemented by creating only {@code private}
 * constructors. However, this constraint cannot be enforced at compile-time in
 * all situations. Some runtime constraint must be employed when a
 * compile-time constraint cannot be specified. Examples are such situations
 * are:
 *
 * <ul>
 *
 * <li>The singleton is used as a plugin in some context that requires plugins
 *     to have a {@code public} no-arg constructor. This is often the case
 *     when using {@link java.util.ServiceLoader}
 *
 * <li>The singlton is loaded lazily from within its own class and the lazy
 *     loading implementation desires to avoid generating a "hidden" accessor
 *     as described in the <a
 *     href="http://pmd.sourceforge.net/rules/design.html#AccessorClassGeneration">PMD
 *     rule "AccessorClassGeneration."</a> Such accessors usually have class
 *     names with suffixes like {@code access$000}.
 *
 * </ul>
 *
 * @see <nobr><a href="http://c2.com/cgi/wiki?DesignPatternsBook">"Design Patterns,"</a> Erich Gamma, et. al., "Singleton"</nobr>
 *
 * @author Greg Mattes
 * @version July 2008
 */
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
@Copyright("Copyright &copy; 2008, Iparelan Solutions, LLC. All rights reserved.")
public @interface Singleton {
}
